package zhongbo.java.air.flightpath.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import zhongbo.java.air.flightpath.config.RedisListenerConfig;
import zhongbo.java.air.flightpath.model.FlightPathl;

@Component
@Slf4j
public class RedisPusChaneIPublisher {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    // 发布消息
    public void sendMessage(String message){
        // 向指定channel发送消息
        redisTemplate.convertAndSend(RedisListenerConfig.LIVE_PATH, message);
        log.info("发送"+message);
    }
    public void sendMessageJson(FlightPathl message) {
        log.info("发送消息live_flight_path: {}", message);
        redisTemplate.convertAndSend(RedisListenerConfig.LIVE_PATH, message);
    }

}
